package com.more.offer.algorithm.sort.sort_03;


/**
 * @author pinoc
 */
public class SelectSort {
	public static void selectSort(int[] array) {
		for (int i = 0; i < array.length - 1; i++) {
			//初始最小值下标 i
			int min = array[i];
			int index = i;
			for (int j = i; j < array.length; j++) {
				if (array[j] < min) {
					min = array[j];
					index = j;
				}
			}
			int temp = array[i];
			array[i] = min;
			array[index] = temp;
		}
	}
}
